#include "bssmapData.h"

typedef bool (*BSSMapParseProcedure)
			(
			GenParmList 		& parmList,
			AddressDigitsList 	& digitsList,
			const unsigned char * pData,
			unsigned int 		  dataLength,
			bool 				  bParseDigits
			);
			
//These functions are all private ones used only by BSSMAP Parser.

static bool parseAssignmentRequest
			(
			GenParmList 		& parmList,
			AddressDigitsList 	& digitsList,
			const unsigned char * pData,
			unsigned int 		  dataLength,
			bool 				  bParseDigits
			);
static bool parseAssignmentComplete
			(
			GenParmList 		& parmList,
			AddressDigitsList 	& digitsList,
			const unsigned char * pData,
			unsigned int 		  dataLength,
			bool 				  bParseDigits
			);
			
static bool parseHandoverRequest
			(
			GenParmList 		& parmList,
			AddressDigitsList 	& digitsList,
			const unsigned char * pData,
			unsigned int 		  dataLength,
			bool 				  bParseDigits
			);
static bool parseHandoverRequired
			(
			GenParmList 		& parmList,
			AddressDigitsList 	& digitsList,
			const unsigned char * pData,
			unsigned int 		  dataLength,
			bool 				  bParseDigits
			);

//used for message types not stipulated in the specification.
static bool parseDefaultMsgType 
			(
			GenParmList 		& parmList,
			AddressDigitsList 	& digitsList,
			const unsigned char * pData,
			unsigned int 		  dataLength,
			bool 				  bParseDigits
			);

BSSMapParseProcedure parsersBssMap[GSMBSSMAP_MAX] = 
			{
				NULL,                   //0
				parseAssignmentRequest, //1
				parseAssignmentComplete,//2
				parseDefaultMsgType,    //3
				parseDefaultMsgType,    //4
				parseDefaultMsgType,    //5
				parseDefaultMsgType,    //6
				parseDefaultMsgType,    //7
				parseDefaultMsgType,    //8
				parseDefaultMsgType,    //9
				parseHandoverRequest,   //10
				parseHandoverRequired   //11
			};

BSSMapData::BSSMapData
	(
	const unsigned char * pDataIn,
	unsigned int		  dataLen,
	bool				  bParseDigits
	)
	{
		dataLen = *pDataIn++ ;
		dataLenIn-- ;
		msgType = *pDataIn++ ;
		dataLen--;
		dataLenIn--;
		pData = pDataIn ;

		BSSMapParseProcedure parseRoutine = parsersBssMap[msgType] ;

		parseRoutine
			(
			*((GenParmList *) this),
			addressDigits,
			pData,
			dataLen,
			bParseDigits
			) ;
	}
	
static bool parseAssignmentRequest
	(
	GenParmList 		& parmList,
	AddressDigitsList 	& digitsList,
	const unsigned char * pData,
	unsigned int 		  dataLength,
	bool 				  bParseDigits
	)
	{
		unsigned int parmType, parmLen ;
		parmType = *pData++ ;
		dataLen--;

		if ( parmType == CHANNEL_TYPE )
		{
			parmLen = *pData++ ;
			dataLen -- ;
			parmList.insert(new GenParmElement(....));
			pData += parmLen ;
			dataLen -= parmLen ;
		}
		...
		return true ;

	}

//Other parser routines are left out.
